import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

public class ColletionsUtilsa {

    public static void main(String[] args) {

        //list
//        Collections.sort();

//        Collections.reverse();


//        collections 查找和替换

        ArrayList<Integer> objects = new ArrayList<>();
        objects.add(-1);
        objects.add(1);
        objects.add(1);
        objects.add(12);
        objects.add(14);

        int i = Collections.binarySearch(objects, 0);
        System.out.println(i);

        //binary 二分查找

        //
//        Integer max = Collections.max(objects, new Comparator<Integer>() {
//            @Override
//            public int compare(Integer o1, Integer o2) {
//                return 0;
//            }
//        });
//        System.out.println(max);
//
//        for (Integer object : objects) {
//            System.out.print(object+" ");
//        }
//        System.out.println();
//
//
//        Collections.fill(objects,2);
//        for (Integer object : objects) {
//            System.out.print(object+" ");
//        }
//        System.out.println();
//
//        System.out.println(Collections.frequency(objects, 2));
//        System.out.println(Collections.frequency(objects, 1));
//
//        Collections.fill(objects,2);
//        for (Integer object : objects) {
//            System.out.print(object+" ");
//        }
        System.out.println("]]]]]");


        ArrayList<Integer> objects1 = new ArrayList<>();
        objects1.add(1);
        objects1.add(1);

        ArrayList<Integer> objects2 = new ArrayList<>();
        objects2.add(12);
        objects2.add(14);
        System.out.println(Collections.indexOfSubList(objects,objects1));
        System.out.println(Collections.lastIndexOfSubList(objects, objects2));

        boolean b = Collections.replaceAll(objects, 1, 99);
        System.out.println(b);


        for (Integer object : objects) {
            System.out.print(object+" ");
        }
        System.out.println();





    }


}
